/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package CastleDefense;

import CastleDefense.units.PlacedUnit;
import java.awt.Image;
import java.util.ArrayList;
import javax.vecmath.Vector2d;

/**
 *
 * @author Firedemon
 */
public class RockProjectile extends PlacedUnit
{
    private double dmg;
    private ArrayList<Enemy> enemies;
    private int waveLife;
    private PlacedUnit parent;
    
    public RockProjectile(double trapDamage, Vector2d loc, Image img, int wl, PlacedUnit parent)
    {
        super(loc,img);
        
        this.dmg      = trapDamage;
        this.parent   = parent;
        this.enemies  = Game.getEnemyList();
        this.waveLife = wl;
    }
    
    @Override
    public void doLogic()
    {
        for(Enemy enemy : enemies)
        {
            if(!enemy.hasRockEffector(this))
            {
                if(this.collidesWith(enemy))
                {
                    enemy.doDamageCalculation(dmg, parent);
                    enemy.addRockEffector(this);
                    return;
                }
            }
        }
    }
    
    public int getWaveLife()
    {
        return waveLife;
    }
}
